package com.icoolkj.mall.order.mapper;

import com.icoolkj.mall.order.dto.OrderResponse;
import com.icoolkj.mall.order.model.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author icoolkj
 * @version 1.0
 * @description
 * @createDate 2025/01/16 14:50
 */
@Mapper
public interface OrderMapper {

    @Insert("INSERT INTO `order` (user_id, product_id, order_quantity, order_cost, create_time, update_time) VALUES (#{userId}, #{productId}, #{orderQuantity}, #{orderCost}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyColumn = "order_id", keyProperty = "orderId")
    int saveOrder(Order order);

    @Select("select * from order where user_id = #{userId} order by order_id desc")
    List<OrderResponse> getOrderByUserId(@Param("userId") String userId);
}
